import { FormOptions, FormType } from '@/models/form'
import { UserStatusOptions } from '@/constant/options'

export function initFormOptions(): FormOptions {
  return {
    title: '用户',
    dialogWidth: '400px',
    labelWidth: 'auto',
    showStatusIcon: true,
    formItems: [
      {
        label: '用户名',
        key: 'username',
        formType: FormType.Input,
        value: '',
        disabledEdit: true,
        placeholder: '请输入用户名',
        rules: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { min: 5, max: 25, message: '长度在 5 到 25 个字符', trigger: 'blur' }
        ]
      },
      {
        label: '昵称',
        key: 'nickname',
        formType: FormType.Input,
        value: '',
        placeholder: '请输入昵称',
        rules: [
          { required: true, message: '请输入昵称', trigger: 'blur' },
          { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }
        ]
      },
      {
        label: '邮箱',
        key: 'email',
        formType: FormType.Input,
        value: '',
        disabledEdit: true,
        placeholder: '请输入Email',
        rules: [
          { required: true, message: '请输入邮箱', trigger: 'blur' },
          {
            min: 5,
            max: 25,
            message: '长度在 5 到 25 个字符',
            trigger: 'blur'
          },
          { type: 'email', message: '请输入有效的邮箱', trigger: 'blur' }
        ]
      },
      {
        label: '密码',
        key: 'password',
        formType: FormType.Input,
        value: '',
        placeholder: '请输入密码',
        rules: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 5, max: 25, message: '长度在 5 到 25 个字符', trigger: 'blur' }
        ]
      },
      {
        label: '手机号',
        key: 'phoneNumber',
        formType: FormType.Input,
        value: '',
        placeholder: '请输入手机号',
        rules: [
          {
            min: 11,
            max: 11,
            message: '请输入有效的11位手机号',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '角色',
        key: 'roleId',
        formType: FormType.Select,
        value: '',
        placeholder: '请选择角色',
        customStyle: 'width: 100%',
        rules: [{ required: true, message: '请选择角色', trigger: 'blur' }]
      },
      {
        label: '状态',
        key: 'status',
        formType: FormType.Select,
        value: '',
        options: UserStatusOptions,
        placeholder: '请选择状态',
        customStyle: 'width: 100%',
        rules: [{ required: true, message: '请选择状态', trigger: 'blur' }]
      },
      {
        label: '描述',
        key: 'description',
        formType: FormType.Input,
        value: '',
        placeholder: '请输入描述信息',
        rules: [{ max: 200, message: '长度最大200', trigger: 'blur' }]
      }
    ]
  }
}
